/*
 * p10859.cpp
 *
 *  Created on: 2013-10-3
 *      Author: zy
 */
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
vector<int> adj[1010];
int vis[1010][2], dp[1010][2], n, m;

int DP(int i, int j, int f)
{
	if (vis[i][j])
		return dp[i][j];
	vis[i][j] = 1;
	int &ans = dp[i][j];

	ans = 2000;
	for (int k = 0; k < adj[i].size(); k++)
		if (adj[i][k] != f)
			ans += DP(adj[i][k], 1, i);
	if (!j && f >= 0)
		ans++;

	if (j || f < 0)
	{
		int sum = 0;
		for (int k = 0; k < adj[i].size(); k++)
			if (adj[i][k] != f)
				sum += DP(adj[i][k], 0, i);
		if (f >= 0)
			sum++;
		ans = min(ans, sum);
	}
	return ans;
}
int main()
{
	int T, a, b;
	scanf("%d", &T);
	while (T--)
	{
		scanf("%d%d", &n, &m);
		for (int i = 0; i < n; i++)
			adj[i].clear();
		for (int i = 0; i < m; i++)
		{
			scanf("%d%d", &a, &b);
			adj[a].push_back(b);
			adj[b].push_back(a);
		}
		memset(vis, 0, sizeof(vis));
		int ans = 0;
		for (int i = 0; i < n; i++)
			if (!vis[i][0])
				ans += DP(i, 0, -1);
		printf("%d %d %d\n", ans / 2000, m - ans % 2000, ans % 2000);
	}
	return 0;
}
